function mean(arr) {
    let total = 0;
    for (let i = 0; i < arr.length; i++) {
        total += arr[i];
    }
    return total / arr.length;
}

function variance(arr) {
    const mu = mean(arr);
    let diffSum = 0;
    for (let i = 0; i < arr.length; i++) {
        diffSum += (arr[i] - mu) ** 2;
    }
    return diffSum / (arr.length - 1);
}

function stddev(arr) {
    return Math.sqrt(variance(arr));
}

// 使用示例
//const numbers = [1, 2, 3, 4, 5];
//const std = stddev(numbers); // 1.4142135623730951
//console.log(std);